<script type="text/javascript">

    	$(document).ready(function(){		
    		getDatePicker('expiry_day');	
    	});
    	
    	// datepicker
    	function getDatePicker(_id) {	
    	$("#"+_id).datepicker({
    		 showOn:'button',
    		 dateFormat:"yy-mm-dd",
    		 buttonImage:'<?php echo $this->baseUrl(); ?>'+'/public/templates/admin/js/calendar/images/calendar.gif',
    		 buttonImageOnly:true,
    		 yearRange: '1900:2020',
    		 changeMonth:true,
    		 changeYear:true,
    		 showMonthAfterYear: true
    		 //minDate:0
    	   });
    	 }
    
    function validate_all(){
        var name = document.getElementById('name').value;
        var pass = document.getElementById('pass').value;
        var repass = document.getElementById('repass').value;
        var phone = document.getElementById('phone').value;
        var birthday = document.getElementById('expiry_day').value;
        var email = document.getElementById('email').value;
        var role = document.getElementById('role').value;
        var gender=document.getElementsByName('gender').checked;
        var status=document.getElementsByName('status').checked;
        if(name=="" || pass=="" || repass==""|| phone=="" ||  birthday=="" ||  email=="" ||  role==0 || gender==false || status==false){
            document.getElementById('error').innerHTML = 'Bạn chưa nhập đầy đủ thông tin!';
            return false;
        }
        else{
            return true;
        }
    }
</script>
<div class="heading">
    <div class="left_heading"></div>
                                
    <div class="content_heading">
        <h3>Thêm thành viên</h3>
    </div>
                                
    <div class="right_heading"></div>
</div><!-- End .heading -->

<div class="main_content">
    <div class="table_form">      
        <form class="list_cat_form" method="post" onsubmit="return validate_all()" enctype="multipart/form-data">
        <div style="float: left;"> 
        <table class="table_adduser" cellpadding="5" > 
            <tr>
                <td class="title_user">Thông tin cá nhân <?php echo $this->email?></td>
            </tr>
            <tr>
                <td class="label" >Họ tên</td>
                <td class="label2"><input class="input" type="text" size="30" name="name" id="name" onchange="return validate_name()"/></td>
                <td ><span class="msg" id="errname"><?php echo $this->errname?></span></td>
            </tr>        
            
            <tr>
                <td>Số điện thoại</td>
                <td><input class="input" type="text" size="30" name="phone" id="phone" onchange="return validate_phone()"/></td>
                <td><span class="msg" id="errphone"><?php echo $this->errphone?></span></td>
            </tr>
            <tr>
                <td>Ngày sinh</td>
                <td><input class="input" type="text" size="30" name="birthday" id="expiry_day"  /></td>
                <td><span class="msg" ><?php echo $this->errbirthday?></span></td>
            </tr>
             <tr>
                <td>Giới tính</td>
                <td>
                    <select class="input" name="gender" id="role">
				        <option value="1">Nam</option>
    				    <option value="0">Nữ</option>
				    </select>
                </td>
                <td><span class="msg"><?php echo $this->errgender?></span></td>
            </tr>
            <tr>
                <td>Ảnh đại diện</td>
                <td><input type="file" name="file" /> </td>
                
            </tr>
            <tr>
                <td class="title_user">Thông tin tài khoản</td>
            </tr>
            <tr>
                <td>Email <span class="msg"> * </span></td>
                <td><input class="input" type="text" size="30" name="email" id="email" onchange="return validate_email()" /></td>
                <td><span class="msg" id="errmail"><?php echo $this->erremail?></span></td>
            </tr>
            
            <tr>
                <td>Mật khẩu <span class="msg"> * </span></td>
                <td><input class="input" type="password" size="30" name="pass" id="pass" /></td>
                <td><span class="msg" ><?php echo $this->errpass?></span></td>
            </tr>
            <tr>
                <td>Nhắc lại mật khẩu <span class="msg"> * </span></td>
                <td><input class="input" type="password" size="30" name="repass" id="repass" onchange="return validate_pass()"/></td>
                <td><span class="msg" id="errpass"><?php echo $this->errrepass?></span></td>
            </tr>
           
            <tr>
                <td>
                    Quyền quản trị <span class="msg"> * </span>
                </td>
                <td>
                    <select class="input" name="role" id="role">
    				    <?php foreach ($this->role as $row){
    				    echo'<option value="'.$row["role_id"].'">'.$row["role_name"].'</option>';
    				    }?>
				    </select>
                </td>
                <td><span class="msg"><?php echo $this->errrole?></span></td>
                
            </tr>
            <tr>
                <td>Cho phép đăng nhập</td>
                <td><input type="radio" name="status" value="1" checked="checked" />Cho phép<input type="radio" name="status" value="0" />Không cho phép</td>
                <td><span class="msg"><?php echo $this->errstatus?></span></td>
            </tr>
            
            <tr>
				<td class="label"></td>
				<td colspan="2">
					<input class="button" type="submit" name="submit" value="Tạo mới"/>
					<input class="button" type="reset" name="reset" value="Nhập lại"/>
					<a href="<?php echo $this->baseUrl('admin/user'); ?>" class="button" style="padding-top: 7px;">Quay lại</a>
				</td>
			</tr>
            <tr>

                <td colspan="2" class="msg"><?php echo $this->err; ?></td>
            </tr>
            <tr>
                <td class="title_user" colspan="2">Những trường <span class="msg"> * </span> là trường bắt buộc phải nhập.</td>
            </tr>
        </table>
        
        </div>
        </form>
    
</div><!-- End .main_content -->  